
interface Obj {
    index:number
}
interface Index<Obj,K>{
    [Obj:string]:number
}

// function getProperty<T extends Index<Obj,K>,K>(obj:T,key:K):number{
//     return obj[key]
// }
function getProperty(obj: T, key: K) {
    return obj[key];
}
let x = { a: 1, b: 2, c: 3, d: 4 };
getProperty(x, "a"); // okay
getProperty(x, "m"); // error: Argument of type 'm' isn't assignable to 'a' | 'b' | 'c' | 'd'.